package app.ep1.seminarios;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
import app.ep1.R;

public class BarcodeActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		TextView tv = new TextView(this);
		tv.setText("Barcode test");
		setContentView(tv);

		IntentIntegrator myIntentIntegrator = new IntentIntegrator(this);
		myIntentIntegrator.initiateScan(null);
	}

	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if (requestCode == IntentIntegrator.REQUEST_CODE) {
			if (resultCode != RESULT_CANCELED) {
				IntentResult scanResult = IntentIntegrator.parseActivityResult(
						requestCode, resultCode, data);

				if (scanResult != null) {
					String upc = scanResult.getContents();

					Intent resultIntent = new Intent();
					resultIntent.putExtra("nusp", upc);
					setResult(Activity.RESULT_OK, resultIntent);
					finish();
				}
			}
		}
	}

}
